import 'package:flutter/material.dart';
import 'package:my_app/utils/log_util.dart';


class CardAndInputPage extends StatefulWidget {
  const CardAndInputPage({super.key});

  @override
  State<CardAndInputPage> createState() => _CardAndInputPageState();
}

class _CardAndInputPageState extends State<CardAndInputPage> {

  final textEditingController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Flutter demo")),
      body: Column(
        children: [
          const Card(
            child: Column(
              children: [
                ListTile(
                  contentPadding: EdgeInsets.symmetric(horizontal: 32.0),
                  title: Text('香树湾新都'),
                  subtitle: Text('灌南县政府南'),
                  // 这样也可以垂直居中
                  leading: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [Icon(Icons.location_city)]
                  ),
                )
              ],
            ),
          ),
          const Card(
            child: Column(
              children: [
                ListTile(
                  title: Text('碧桂园世纪城'),
                  subtitle: Text('郭庄奥莱'),
                  leading: Icon(Icons.home),
                ),
              ],
            ),
          ),
          const Card(
            child: Column(
              children: [
                ListTile(
                  title: Text('香树湾新都'),
                  subtitle: Text('灌南县政府南'),
                  // 这样也可以垂直居中
                  leading: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [Icon(Icons.location_city)]
                  ),
                )
              ],
            ),
          ),
          TextField(
            controller: textEditingController,
            decoration: const InputDecoration(
                icon: Icon(Icons.people),
                labelText: "username",
                hintText: "请输入用户名",
                border: InputBorder.none,
                filled: true,
                fillColor: Colors.lightGreen
            ),
            onChanged: (val) {
                LogUtil.d("onChanged: $val");
            },
            onSubmitted: (val) {
                LogUtil.d("onSubmitted: $val");
            },
          ),
        ],
      )
    );
  }
}
